/**
 * ReportGear(2011)
 */
package com.reportgear.report.model;

import org.dom4j.Element;

import com.sot.core.util.NumberUtils;

/**
 * 报表模型读写器
 * 
 * @version 1.0 2011-6-9
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class SalaryReportModelReader extends ReportModelReader {
	/**
	 * 写入基本信息,子类可扩充自己的信息
	 * 
	 * @param root
	 *            根节点
	 * @param model
	 *            模型
	 */
	@Override
	protected void writeBaseInfo(Element root, ReportModel model) {
		super.writeBaseInfo(root, model);

		if (model instanceof SalaryReportModel) {
			SalaryReportModel salaryModel = (SalaryReportModel) model;

			Element baseEl = root.element("base");

			Element el;
			el = baseEl.addElement("scheme");
			el.addText(String.valueOf(salaryModel.getScheme()));
		}
	}

	/**
	 * 读入属性
	 * 
	 * @param root
	 *            根节点
	 */
	@Override
	protected void readBaseInfo(Element root, ReportModel model) {
		super.readBaseInfo(root, model);

		if (model instanceof SalaryReportModel) {
			SalaryReportModel salaryModel = (SalaryReportModel) model;

			Element el = root.element("base");
			salaryModel.setScheme(NumberUtils.convertToInteger(el.elementText("scheme")));
		}
	}
}
